import 'package:banyou_app/app/request/http_request.dart';
import 'package:get/get.dart';

class XiangquController extends GetxController {
  //TODO: Implement XiangquController

  final count = 0.obs;
  final bannerList = [].obs;
  final citysList = [].obs;
  final attractionsList = [].obs;
  @override
  void onInit() {
    loadData();
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  loadData() async {
    final result =
        await HttpRequest.get('https://aqcdn.olbibo.com.cn/LikeGo.json');
    if (result.result) {
      List map = result.data ?? [];
      map.forEach((element) {
        if (element['LikeGo'] != null) {
          bannerList.value = element['LikeGo']['Data'] ?? [];
        } else if (element['Pos'] == 'Citys') {
          citysList.value = element['Data'] ?? [];
        } else if (element['Pos'] == 'Attractions') {
          attractionsList.value = element['Data'] ?? [];
        }
      });
    }
  }

  @override
  void onClose() {}
  void increment() => count.value++;
}
